package com.jacobson.huobi.mvp.presenter

import com.jacobson.core.di.annotation.ActivityScope
import com.jacobson.core.mvp.BasePresenter
import com.jacobson.huobi.common.expansion.applySchedulersIoMain
import com.jacobson.huobi.common.expansion.onPageRespResult
import com.jacobson.huobi.common.expansion.onRespResult
import com.jacobson.huobi.common.expansion.onResponseResult
import com.jacobson.huobi.mvp.contract.InviteDetailsContract
import io.reactivex.functions.Consumer
import javax.inject.Inject

@ActivityScope
class InviteUserListPresenter  @Inject constructor(
    view: InviteDetailsContract.View,
    model: InviteDetailsContract.Model
) : BasePresenter<InviteDetailsContract.View, InviteDetailsContract.Model>(view, model),
    InviteDetailsContract.Presenter {
    override fun loadInviteUserList(page: Int) {
        model.loadInviteUserList(page)
            .applySchedulersIoMain()
            .onPageRespResult(view) { resp ->
                view?.onInviteUserResp(resp)
            }
    }

    override fun getSharedInfo() {
        model.getSharedInfo()
            .applySchedulersIoMain()
            .doOnNext {
                view?.onSharedInfoResp(it)
            }
            .subscribe()
    }
}